home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The Essential Home & Business Collection
/
The Essential Home & Business Collection.iso
/
23
/
0
/
3
/
DISK2303.ZIP
/
SAMPLE.C
< prev
next >
Wrap
Text File
|
1989-11-08
|
5KB
|
169 lines
/*-----------------------------------------------------------------------
| Sample.c |
| |
| This program is an example of how the C arrays of |
| structures generated by Screen Machine can be displayed. |
| |
| Note: |
| Screen Machine always generates the structure "_scrn". If |
| you are including more than one screen generated by Screen |
| Machine in a given program, only one declaration of the |
| "_scrn" structure should be copied into the program. |
| |
| |
-----------------------------------------------------------------------*/
/*various include files*/
#include <stdio.h>
#include <graph.h>
#include <bios.h>
#include <dos.h>
#define FALSE 0
#define TRUE 1
#define VIDEO 0x10 /*Software interrupt 0x10 */
#define WRITE_ATTR_CHAR 9 /*Function 9 */
void disp_screen(struct _scrn *, unsigned short );
struct _scrn {
char *chrs;
char cw;
char rw;
char att;
};
struct _scrn screen_sample[]={
{"╔══════════════════════════════════════════════════════╗",14,7,31},
{"║ ║",14,8,31},
{"║ ",14,9,31},
{"┌────────────────────────────────────────┐",20,9,121},
{" ║",62,9,31},
{"║ ",14,10,31},
{"│",20,10,121},
{" ",21,10,31},
{"│",61,10,121},
{" ║",62,10,31},
{"║ ",14,11,31},
{"│",20,11,121},
{" ",21,11,31},
{" testing this ",23,11,122},
{" ",43,11,31},
{"│",61,11,121},
{" ║",62,11,31},
{"║ ",14,12,31},
{"│",20,12,121},
{" ",21,12,31},
{" program ",23,12,122},
{" ",43,12,31},
{"│",61,12,121},
{" ║",62,12,31},
{"║ ",14,13,31},
{"│",20,13,121},
{" ",21,13,31},
{" ",23,13,122},
{" ",43,13,31},
{"│",61,13,121},
{" ║",62,13,31},
{"║ ",14,14,31},
{"│",20,14,121},
{" ",21,14,31},
{"│",61,14,121},
{" ║",62,14,31},
{"║ ",14,15,31},
{"└────────────────────────────────────────┘",20,15,121},
{" ║",62,15,31},
{"║ ║",14,16,31},
{"║ ║",14,17,31},
{"╚══════════════════════════════════════════════════════╝",14,18,31},
{" wow!!! ",56,19,12},
{" ",56,20,12},
{"\0",0,0,0}
};
struct _scrn screen_little[]={
{"┌───────────────────┐",5,22,31},
{"│ Little ",5,23,31},
{"Window",14,23,121},
{" │",20,23,31},
{"└───────────────────┘",5,24,31},
{"\0",0,0,0}
};
long color_back_grnd= 1; /*All screens will use a blue background*/
main()
{
disp_screen(screen_sample, TRUE); /*Clear screen and then display the screen defined by screen_sample*/
disp_screen(screen_little, FALSE); /*display screen defined by screen_little without clearing the screen */
_bios_keybrd(_KEYBRD_READ); /*wait for a key*/
}
/*-----------------------------------------------------------
| disp_screen - Use ptr passed to array of structures |
| containing &text; col; row; and attribute. |
| Use BIOS int 10h function 9 to display the |
| data. |
| |
| If cls_flag is TRUE, clear the screen before|
| displaying the data. When clearing the |
| screen, use the attribute defined in the |
| variable color_back_grnd |
| |
| |
| |
------------------------------------------------------------*/
void disp_screen(p, cls_flag)
struct _scrn *p;
unsigned short cls_flag;
{
char work;
char wrow;
char wcol;
char * wsptr;
union REGS inregs, outregs;
if (cls_flag)
{
_setbkcolor(color_back_grnd);
_clearscreen(_GCLEARSCREEN);
}
inregs.h.ah = WRITE_ATTR_CHAR; /*print char and attribute*/
inregs.x.cx = 1; /*Print 1 char*/
while ( *(p->chrs) )
{
wsptr=p->chrs; /*Get ptr to string*/
wcol=p->cw;
inregs.h.bh = 0; /*Video page 0*/
inregs.h.bl = p->att; /*Attribute to use */
while (inregs.h.al = *wsptr++) /*Char to print*/
{
/*Position the cursor*/
_settextposition( (short) p->rw, (short) wcol++);
int86 ( VIDEO, &inregs, &outregs ); /*Print with BIOS*/
}
p++;
}
}